package com.brzjomo.secretiveworld.world.gen;

import com.brzjomo.secretiveworld.init.ModBiomeTypes;
import com.brzjomo.secretiveworld.init.ModFeatures;
import com.brzjomo.secretiveworld.world.gen.feature.structure.abandoned.house.AbandonedHouseConfig;
import com.brzjomo.secretiveworld.world.gen.feature.structure.corpse.CorpseOfAnUnknownTravelerConfig;
import com.brzjomo.secretiveworld.world.gen.feature.structure.test.TestStructureConfig;

import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage.Decoration;
import net.minecraft.world.gen.placement.IPlacementConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;

public class ModStructureGen {
	// possibility
	private static final double TEST_STRUCTURE_PROBABILITY = 0.005D;
	private static final double ABANDONED_HOUSE_PROBABILITY = 0.003D;
	private static final double CORPSE_OF_AN_UNKNOWN_TRAVELER_PROBABILITY = 0.006D;

	// biome
	private static final Biome[] TEST_STRUCTURE_BIOME = { Biomes.PLAINS };
	private static final Biome[] ABANDONED_HOUSE_BIOME = { Biomes.DARK_FOREST };
	private static final Biome[] CORPSE_OF_AN_UNKNOWN_TRAVELER_BIOME = { Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS,
			Biomes.ICE_SPIKES, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS,
			Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS, Biomes.SWAMP, Biomes.JUNGLE, Biomes.JUNGLE_HILLS,
			Biomes.MODIFIED_JUNGLE, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.DESERT_LAKES, Biomes.BADLANDS,
			Biomes.BADLANDS_PLATEAU, Biomes.MODIFIED_BADLANDS_PLATEAU, Biomes.ERODED_BADLANDS };

	public static void structureGen() {
		for (Biome biome : ForgeRegistries.BIOMES) {
			for (Biome i : TEST_STRUCTURE_BIOME) {
				if (biome == i) {
					biome.addStructure(ModFeatures.TEST_STRUCTURE.get()
							.withConfiguration(new TestStructureConfig(TEST_STRUCTURE_PROBABILITY)));
				}
			}

			for (Biome i : ABANDONED_HOUSE_BIOME) {
				if (biome == i) {
					biome.addStructure(ModFeatures.ABANDONED_HOUSE.get()
							.withConfiguration(new AbandonedHouseConfig(ABANDONED_HOUSE_PROBABILITY)));
				}
			}

			for (Biome i : CORPSE_OF_AN_UNKNOWN_TRAVELER_BIOME) {
				if (biome == i) {
					biome.addStructure(ModFeatures.CORPSE_OF_AN_UNKNOWN_TRAVELER.get().withConfiguration(
							new CorpseOfAnUnknownTravelerConfig(CORPSE_OF_AN_UNKNOWN_TRAVELER_PROBABILITY)));
				}
			}

			biome.addFeature(Decoration.SURFACE_STRUCTURES,
					ModFeatures.TEST_STRUCTURE.get()
							.withConfiguration(new TestStructureConfig(TEST_STRUCTURE_PROBABILITY))
							.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));

			biome.addFeature(Decoration.SURFACE_STRUCTURES,
					ModFeatures.ABANDONED_HOUSE.get()
							.withConfiguration(new AbandonedHouseConfig(ABANDONED_HOUSE_PROBABILITY))
							.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));

			biome.addFeature(Decoration.SURFACE_STRUCTURES,
					ModFeatures.CORPSE_OF_AN_UNKNOWN_TRAVELER.get()
							.withConfiguration(
									new CorpseOfAnUnknownTravelerConfig(CORPSE_OF_AN_UNKNOWN_TRAVELER_PROBABILITY))
							.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));

		}
	}
}
